//
//  CryptoUtil.h
//  iPhoneLib,
//  Helper Functions and Classes for Ordinary Application Development on iPhone
//
//  Created by meinside on 10. 01. 16.
//
//  last update: 10.07.21.
//

#pragma once
#import <Foundation/Foundation.h>

//needs: Security.framework


@interface CryptoUtil : NSObject {

}

+ (BOOL)generateRSAKeyWithKeySizeInBits:(int)keyBits publicKeyTag:(NSString*)publicTag privateKeyTag:(NSString*)privateTag;


+ (NSData*)generateRSAPublicKeyWithModulus:(NSData*)modulus exponent:(NSData*)exponent;

+ (BOOL)saveRSAPublicKey:(NSData*)publicKey appTag:(NSString*)appTag overwrite:(BOOL)overwrite;

+ (BOOL)updateRSAPublicKey:(NSData*)publicKey appTag:(NSString*)appTag;

+ (SecKeyRef)loadRSAPublicKeyRefWithAppTag:(NSString*)appTag;

+ (NSData*)encryptString:(NSString*)original RSAPublicKey:(SecKeyRef)publicKey padding:(SecPadding)padding;

+ (BOOL)deleteRSAPublicKeyWithAppTag:(NSString*)appTag;

+ (SecKeyRef)RSAPublicKeyRefFromBase64String:(NSString *)key withTag:(NSString *)tag;


@end
